ifndef HEO_PATH
HEO_PATH = ../../../..
endif

HEO_RELEASE = -O3
HEO_DEBUG = -O0 -DDEBUG

CXXFLAGS += $(HEO_CXXFLAGS)
LDFLAGS += $(HEO_LDFLAGS)

.PHONY: release debug clean

release: ./Release/$(PROJECT)

debug: ./Debug/$(PROJECT)

./Release/$(PROJECT): $(addprefix ./Release/, $(PROJECT_SRC:.cpp=.o)) $(addprefix ./Release/heo/,$(HEO_SRC:.cpp=.o))
	$(HEO_CXX) $(CXXFLAGS) $(HEO_RELEASE) $(LDFLAGS) $^ -o $@

./Release/%.o: %.cpp
	mkdir -p ./Release
	$(HEO_CXX) $(CXXFLAGS) $(HEO_RELEASE) -c $< -o $@

./Release/heo/%.o: $(HEO_PATH)/src/heo/%.cpp
	mkdir -p ./Release/heo
	$(HEO_CXX) $(CXXFLAGS) $(HEO_RELEASE) -c $< -o $@

./Debug/$(PROJECT): $(addprefix ./Debug/, $(PROJECT_SRC:.cpp=.o)) $(addprefix ./Debug/heo/,$(HEO_SRC:.cpp=.o))
	$(HEO_CXX) $(CXXFLAGS) $(HEO_DEBUG) $(LDFLAGS) $^ -o $@

./Debug/%.o: %.cpp
	mkdir -p ./Debug
	$(HEO_CXX) $(CXXFLAGS) $(HEO_DEBUG) -c $< -o $@

./Debug/heo/%.o: $(HEO_PATH)/src/heo/%.cpp
	mkdir -p ./Debug/heo
	$(HEO_CXX) $(CXXFLAGS) $(HEO_DEBUG) -c $< -o $@

clean:
	rm -rf ./Release
	rm -rf ./Debug
